 void setup(){
//pinMode(5, OUTPUT);
//setPwmFrequency(9, 1);
//     TCCR0B = TCCR0B & 0b11111000 | 0x02;
  analogWrite(9,10);
//TCCR3B = TCCR3B & 0b1111000 | 0x01; // 5 is on timer 3
TCCR2B = TCCR2B & 0b1111000 | 0x01;
//3rd comment
//2nd Comment for testing Tortoise SVN
Serial.begin(9600); //Serial output for testing
}  

  void loop() {
//      TCCR0B = TCCR0B & 0b11111000 | 0x04;
unsigned long time;
unsigned long time2;
unsigned long timeDiff;
  int STEPS = 100;
  int DELAY_MILLIS = 10;
  double rads;
  int scaled_output;
  double HZ = 1; // in hz freq
  double output;
  double STEP_SIZE = 2 * PI / STEPS;
  double temp;
  
  time = micros();
  
  for(int i = 0; i < STEPS; i++){ // full loop takes 20,000us 
    rads = STEP_SIZE * i; //rads steps from 0 to one STEP_SIZE below a full revolution
    output = sin(rads);   
    scaled_output = map(output*100, -100, 100, 0, 255); // map to range of PWM pin
    analogWrite(9,scaled_output); //Output to pin 9
    //Serial.println(scaled_output);
    
    //temp =  ((1/HZ)*1e6 - 20055)/STEPS; //not science
    delayMicroseconds((  (1/HZ)*1e6 - 20055)/STEPS); //delay until next iteration
    //delayMicroseconds(1);
  }
  
  time2 = micros();
  timeDiff = time2 - time;
  Serial.println(timeDiff);
  
  
//  TCCR0B = TCCR0B & 0b11111000 | 0x04;
}

//void setPwmFrequency(int pin, int divisor) {
//  byte mode;
//  if(pin == 5 || pin == 6 || pin == 9 || pin == 10) {
//    switch(divisor) {
//      case 1: mode = 0x01; break;
//      case 8: mode = 0x02; break;
//      case 64: mode = 0x03; break;
//      case 256: mode = 0x04; break;
//      case 1024: mode = 0x05; break;
//      default: return;
//    }
//    if(pin == 5 || pin == 6) {
//      TCCR0B = TCCR0B & 0b11111000 | mode;
//    } else {
//      TCCR1B = TCCR1B & 0b11111000 | mode;
//    }
//  } else if(pin == 3 || pin == 11) {
//    switch(divisor) {
//      case 1: mode = 0x01; break;
//      case 8: mode = 0x02; break;
//      case 32: mode = 0x03; break;
//      case 64: mode = 0x04; break;
//      case 128: mode = 0x05; break;
//      case 256: mode = 0x06; break;
//      case 1024: mode = 0x7; break;
//      default: return;
//    }
//    TCCR2B = TCCR2B & 0b11111000 | mode;
//  }
//}
